import instance from './index';
import qs from 'qs';

const preUrlPath = '';
//获取委托订单列表-分页
const request = {
  p: ['api:user:fetch'],
  r: params => {
    return instance.get(`/v1/trade/fetchEntrustOrderPageList`, {params}).catch(function(res){
      console.log(res)
    })
  }
};

//添加委托订单
const add = {
  p: ['api:user:new'],
  r: params => {
    return instance.post(`/v1/coin/new`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};
//获取委托订单信息
const info = {
  p: ['get'],
  r: params => {
    return instance.get(`/v1/coin/info`, {params}).catch(function(res){
      console.log(res)
    })
  }
};
//取消委托订单
const cancel = {
  p: ['api:user:modify'],
  r: params => {
    return instance.post(`/v1/trade/cancelEntrustOrder`, qs.stringify(params),{ headers:{'Content-Type':'application/x-www-form-urlencoded'}}).catch(function(res){
      console.log(res)
    })
  }
};


//越权请求
const notAllowed = {
  p: ['get,/roles/notAllowed'],
  r: params => {
    return instance.get(`${preUrlPath}/GET/roles/notAllowed`, {params})
  }
}

export {
  request,
  notAllowed,
  add,
  cancel,
  info,
}
